package controllers

import (
	"newWebwithGo/models"

	"github.com/astaxie/beego"
	"github.com/astaxie/beego/orm"
)

type MainController struct {
	beego.Controller
}

// 1.这里写插入语句
// 2.插入的结构体对象
// 3.对结构体对象赋值
// 4.插入

func (c *MainController) Get() {
	o := orm.NewOrm()
	user := models.User{}
	user.Name = "1111"
	user.Pwd = "222"
	_, err := o.Insert(&user)
	if err != nil {
		beego.Info("插入失败", err)
		return
	}

	c.Data["Website"] = "beego.me"
	c.Data["Email"] = "astaxie@gmail.com"
	c.TplName = "test.html"
	c.Data["data"] = "天冷多穿衣服"

}

func (c *MainController) Post() {
	c.Data["data"] = "天热少穿衣服"
	c.TplName = "test.html"
}
